<template>
	<avue-crud :option="option" :data="data" :page="page" v-model="form" ref="crud" @selection-change="selectionChange"
	 @search-change="searchChange" @search-reset="searchReset" @on-load="onLoad">
		<template slot="menuLeft">
			<el-button type="primary" size="mini" @click.stop="handleClose">确定</el-button>
		</template>
	</avue-crud>
</template>

<script>
	import request from '@/router/axios';

	export default {
		props: {
			selectionList: {},
			storeCode: ''
		},
		data() {
			return {
				selects: [],
				form: {},
				query: {},
				page: {
					pageSize: 10,
					currentPage: 1,
					total: 0
				},
				option: {
					size: "mini",
					selection: true,
					searchShow: false,
					searchMenuSpan: 6,
					border: true,
					refreshBtn: false,
					addBtn: false,
					menu: false,
					column: [{
							label: "箱号",
							prop: "boxNum",
							searchPlaceholder: '箱号',
							search: true,
							width: 180
						},
						{
							label: "客户号",
							prop: "customCode",
							search: true,
							width: 150
						},
						{
							label: "纸箱类型",
							prop: "boxType"
						},
						{
							label: "数量",
							prop: "quantity",
							width: 100
						},
						{
							label: "重量",
							prop: "weight",
							width: 100
						},
						{
							label: "体积",
							prop: "volume",
							width: 100
						},
						{
							label: "时间",
							prop: "createdOn",
							width: 160
						}
					]
				},
				data: []
			};
		},
		computed: {},
		created() {},
		mounted() {},
		methods: {
			handleClose() {
				this.$emit('closeDialog', this.selects)
			},
			selectionChange(list) {
				this.selects = list;
			},
			searchReset() {
				this.query = {};
				this.page.currentPage = 1;
				this.onLoad(this.page);
			},
			searchChange(params, done) {
				this.query = params;
				this.page.currentPage = 1;
				this.onLoad(this.page);
				done();
			},
			onLoad(page) {
				request({
					url: '2/api/OrderPkg/pages',
					params: {
						key: this.query.boxNum == undefined ? '' : this.query.boxNum,
						type: this.query.customCode == undefined ? '' : this.query.customCode,
						where: this.storeCode == undefined ? '' : this.storeCode,
						status: 0,
						page: page.currentPage,
						limit: page.pageSize
					}
				}).then(res => {
					const data = res.data
					this.data = data.data;
					this.page.total = data.remark;
				});
			}
		}
	};
</script>

<style>
	.avue-crud__menu {
		min-height: 0px;
	}

	.el-dialog__body {
		padding-top: 0px;
	}
</style>
